module.exports = function (babel) {
  const { types: t, template } = babel;
  return {
    name: "my-plugin",
    visitor: {
      // path: 当前节点路径, state // 传入的参数
      FunctionDeclaration(path, state) {
        const temp = template(`
        if(something) {
          NORMAL_RETURN
        } else {
          return '${state.opts.whenFalsy}'
        }
      `);
        const returnNode = path.node.body.body[0];
        const tempAst = temp({
          NORMAL_RETURN: returnNode,
        });
        path.node.body.body[0] = tempAst;
      },
    },
  };
};
